package com.cloudservice.ccs.mapper;

import com.cloudservice.ccs.entity.Session;
import com.cloudservice.ccs.model.SessionWithLatestMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;


import java.util.List;
import java.util.Map;

@Mapper
public interface SessionMapper {
    int save(Session session);

    int update(Integer id, Session session);

    int partialUpdate(Integer id, Map<String, Object> fields);

    int delete(Integer id);

    Session getOne(Integer id);

    List<Session> getAll();

    List<Session> getWithConditions(@Param("conditions") Map<String, Object> conditions);

    List<SessionWithLatestMessage> getWithLatestMessage(Integer customerServiceId);

    List<SessionWithLatestMessage> getWithActiveStatusWithLatestMessage(Integer customerServiceId, Boolean activeStatus);

    Session getByCustomerServiceAndVisitor(Integer customerServiceId, String visitorIp);

    Session getAvailableSession(String visitorIp);
}
